#include <iostream>
using namespace std;

/*
    特殊运算符
        自增：前置++ 后置++
            前置++和后置++的运算符重载 --> 同名、同参、同返回值
            解决办法：后置的自增和自减需要添加int类型的参数，跟前置的进行区分
        自减：同理
*/

class Cat
{
public:
    Cat(string _name, int _age) 
    {
        name = _name;
        age = _age;
    }
    Cat(){}
    void show()
    {
        cout << "name:" << name << " age:" << age << endl;
    }
    // 后置
    Cat operator++(int n)
    {
        cout << "后置++"<< endl;
        Cat temp;
        temp = *this;
        this->age += 1;
        return temp;
    }
    // 前置
    Cat operator++()
    {
        cout << "前置++"<< endl;
        this->age += 1;
        return *this;
    }
    // 后置--
    Cat operator--(int n)
    {
        cout << "后置--"<< endl;
        Cat temp;
        temp = *this;
        this->age -= 1;
        return temp;
    }
    // 前置--
    Cat operator--()
    {
        cout << "前置--"<< endl;
        this->age -= 1;
        return *this;
    }

private:
    string name;
    int age;
};


 int main()
 {
    Cat c1("汤姆", 10);
    c1.show();
    // Cat c2 = c1.operator++(32);
    Cat c2 = c1++;
    c1.show();
    c2.show();
    Cat c3 = ++c1;
    c1.show();
    c3.show();
    cout << "------------------" << endl;
    Cat c4 = c1--;
    c1.show();
    c4.show();
    Cat c5 = --c1;
    c1.show();
    c5.show();

    return 0;
 }